#!/bin/env python
"""https://docs.blender.org/api/current/bpy_types_enum_items/icon_items.html"""
bl_info = {
    "name": "bpy icons",
    "description": "search/preview bpy icons",
    "author": "Nolca",
    "version": (0, 1, 0),
    "blender": (2, 80, 0),
    "location": "3D View > Development",
    "warning": "",  # used for warning icon and text in addons panel
    "wiki_url": "",
    "category": "Development",
}

import re
import bpy
ICONS = [
    'NONE', 'BLANK1', 'AUTOMERGE_OFF', 'AUTOMERGE_ON', 'CHECKBOX_DEHLT', 'CHECKBOX_HLT', 'CLIPUV_DEHLT', 'CLIPUV_HLT', 'DECORATE_UNLOCKED', 'DECORATE_LOCKED', 'FAKE_USER_OFF',
    'FAKE_USER_ON', 'HIDE_ON', 'HIDE_OFF', 'INDIRECT_ONLY_OFF', 'INDIRECT_ONLY_ON', 'ONIONSKIN_OFF', 'ONIONSKIN_ON', 'UNPINNED', 'PINNED', 'RADIOBUT_OFF', 'RADIOBUT_ON',
    'RECORD_OFF', 'RECORD_ON', 'RESTRICT_RENDER_ON', 'RESTRICT_RENDER_OFF', 'RESTRICT_SELECT_ON', 'RESTRICT_SELECT_OFF', 'RESTRICT_VIEW_ON', 'RESTRICT_VIEW_OFF', 'RIGHTARROW', 'DOWNARROW_HLT', 'SELECT_INTERSECT',
    'SELECT_DIFFERENCE', 'SNAP_OFF', 'SNAP_ON', 'UNLOCKED', 'LOCKED', 'VIS_SEL_11', 'VIS_SEL_10', 'VIS_SEL_01', 'VIS_SEL_00', 'CANCEL', 'ERROR',
    'QUESTION', 'ADD', 'ARROW_LEFTRIGHT', 'AUTO', 'BLENDER', 'BORDERMOVE', 'BRUSHES_ALL', 'CHECKMARK', 'COLLAPSEMENU', 'COLLECTION_NEW', 'COLOR',
    'COPY_ID', 'DISCLOSURE_TRI_DOWN', 'DISCLOSURE_TRI_RIGHT', 'DOT', 'DRIVER_DISTANCE', 'DRIVER_ROTATIONAL_DIFFERENCE', 'DRIVER_TRANSFORM', 'DUPLICATE', 'EYEDROPPER', 'FCURVE_SNAPSHOT', 'FILE_NEW',
    'FILE_TICK', 'FREEZE', 'FULLSCREEN_ENTER', 'FULLSCREEN_EXIT', 'GHOST_DISABLED', 'GHOST_ENABLED', 'GRIP', 'HAND', 'HELP', 'LINKED', 'MENU_PANEL',
    'NODE_SEL', 'NODE', 'OBJECT_HIDDEN', 'OPTIONS', 'PANEL_CLOSE', 'PLUGIN', 'PLUS', 'PRESET_NEW', 'QUIT', 'RECOVER_LAST', 'REMOVE',
    'RIGHTARROW_THIN', 'SCREEN_BACK', 'STATUSBAR', 'STYLUS_PRESSURE', 'THREE_DOTS', 'TOPBAR', 'TRASH', 'TRIA_DOWN', 'TRIA_LEFT', 'TRIA_RIGHT', 'TRIA_UP',
    'UNLINKED', 'URL', 'VIEWZOOM', 'WINDOW', 'WORKSPACE', 'X', 'ZOOM_ALL', 'ZOOM_IN', 'ZOOM_OUT', 'ZOOM_PREVIOUS', 'ZOOM_SELECTED',
    'MODIFIER', 'PARTICLES', 'PHYSICS', 'SHADERFX', 'SPEAKER', 'OUTPUT', 'SCENE', 'TOOL_SETTINGS', 'LIGHT', 'MATERIAL', 'TEXTURE',
    'WORLD', 'ANIM', 'SCRIPT', 'GEOMETRY_NODES', 'TEXT', 'ACTION', 'ASSET_MANAGER', 'CONSOLE', 'FILEBROWSER', 'GEOMETRY_SET', 'GRAPH',
    'IMAGE', 'INFO', 'NLA', 'NODE_COMPOSITING', 'NODE_MATERIAL', 'NODE_TEXTURE', 'NODETREE', 'OUTLINER', 'PREFERENCES', 'PROPERTIES', 'SEQUENCE',
    'SOUND', 'SPREADSHEET', 'TIME', 'TRACKER', 'UV', 'VIEW3D', 'EDITMODE_HLT', 'OBJECT_DATAMODE', 'PARTICLEMODE', 'POSE_HLT', 'SCULPTMODE_HLT',
    'TPAINT_HLT', 'UV_DATA', 'VPAINT_HLT', 'WPAINT_HLT', 'TRACKER_DATA', 'TRACKING_BACKWARDS_SINGLE', 'TRACKING_BACKWARDS', 'TRACKING_CLEAR_BACKWARDS', 'TRACKING_CLEAR_FORWARDS', 'TRACKING_FORWARDS_SINGLE', 'TRACKING_FORWARDS',
    'TRACKING_REFINE_BACKWARDS', 'TRACKING_REFINE_FORWARDS', 'TRACKING', 'GROUP', 'CONSTRAINT_BONE', 'CONSTRAINT', 'ARMATURE_DATA', 'BONE_DATA', 'CAMERA_DATA', 'CURVE_DATA', 'EMPTY_DATA',
    'FONT_DATA', 'LATTICE_DATA', 'LIGHT_DATA', 'MESH_DATA', 'META_DATA', 'PARTICLE_DATA', 'SHAPEKEY_DATA', 'SURFACE_DATA', 'OBJECT_DATA', 'RENDER_RESULT', 'RENDERLAYERS',
    'SCENE_DATA', 'BRUSH_DATA', 'IMAGE_DATA', 'LINE_DATA', 'MATERIAL_DATA', 'TEXTURE_DATA', 'WORLD_DATA', 'ANIM_DATA', 'BOIDS', 'CAMERA_STEREO', 'COMMUNITY',
    'FACE_MAPS', 'FCURVE', 'FILE', 'GREASEPENCIL', 'GREASEPENCIL_LAYER_GROUP', 'GROUP_BONE', 'GROUP_UVS', 'GROUP_VCOL', 'GROUP_VERTEX', 'LIBRARY_DATA_BROKEN', 'LIBRARY_DATA_DIRECT',
    'LIBRARY_DATA_OVERRIDE', 'ORPHAN_DATA', 'PACKAGE', 'PRESET', 'RENDER_ANIMATION', 'RENDER_STILL', 'RNA_ADD', 'RNA', 'STRANDS', 'UGLYPACKAGE', 'MOUSE_LMB',
    'MOUSE_MMB', 'MOUSE_RMB', 'MOUSE_MMB_SCROLL', 'MOUSE_LMB_2X', 'MOUSE_MOVE', 'MOUSE_LMB_DRAG', 'MOUSE_MMB_DRAG', 'MOUSE_RMB_DRAG', 'DECORATE_ANIMATE', 'DECORATE_DRIVER', 'DECORATE_KEYFRAME',
    'DECORATE_LIBRARY_OVERRIDE', 'DECORATE_LINKED', 'DECORATE_OVERRIDE', 'DECORATE', 'OUTLINER_COLLECTION', 'CURVES_DATA', 'OUTLINER_DATA_ARMATURE', 'OUTLINER_DATA_CAMERA', 'OUTLINER_DATA_CURVE', 'OUTLINER_DATA_CURVES', 'OUTLINER_DATA_EMPTY',
    'OUTLINER_DATA_FONT', 'OUTLINER_DATA_GP_LAYER', 'OUTLINER_DATA_GREASEPENCIL', 'OUTLINER_DATA_LATTICE', 'OUTLINER_DATA_LIGHT', 'OUTLINER_DATA_LIGHTPROBE', 'OUTLINER_DATA_MESH', 'OUTLINER_DATA_META', 'OUTLINER_DATA_POINTCLOUD', 'OUTLINER_DATA_SPEAKER', 'OUTLINER_DATA_SURFACE',
    'OUTLINER_DATA_VOLUME', 'POINTCLOUD_DATA', 'POINTCLOUD_POINT', 'VOLUME_DATA', 'OUTLINER_OB_ARMATURE', 'OUTLINER_OB_CAMERA', 'OUTLINER_OB_CURVE', 'OUTLINER_OB_CURVES', 'OUTLINER_OB_EMPTY', 'OUTLINER_OB_FONT', 'OUTLINER_OB_FORCE_FIELD',
    'OUTLINER_OB_GREASEPENCIL', 'OUTLINER_OB_GROUP_INSTANCE', 'OUTLINER_OB_IMAGE', 'OUTLINER_OB_LATTICE', 'OUTLINER_OB_LIGHT', 'OUTLINER_OB_LIGHTPROBE', 'OUTLINER_OB_MESH', 'OUTLINER_OB_META', 'OUTLINER_OB_POINTCLOUD', 'OUTLINER_OB_SPEAKER', 'OUTLINER_OB_SURFACE',
    'OUTLINER_OB_VOLUME', 'GP_MULTIFRAME_EDITING', 'GP_ONLY_SELECTED', 'GP_SELECT_BETWEEN_STROKES', 'GP_SELECT_POINTS', 'GP_SELECT_STROKES', 'HOLDOUT_OFF', 'HOLDOUT_ON', 'MODIFIER_OFF', 'MODIFIER_ON', 'RESTRICT_COLOR_OFF',
    'RESTRICT_COLOR_ON', 'RESTRICT_INSTANCED_OFF', 'RESTRICT_INSTANCED_ON', 'LIGHT_AREA', 'LIGHT_HEMI', 'LIGHT_POINT', 'LIGHT_SPOT', 'LIGHT_SUN', 'LIGHTPROBE_PLANE', 'LIGHTPROBE_SPHERE', 'LIGHTPROBE_VOLUME',
    'COLOR_BLUE', 'COLOR_GREEN', 'COLOR_RED', 'CONE', 'CUBE', 'CURVE_BEZCIRCLE', 'CURVE_BEZCURVE', 'CURVE_NCIRCLE', 'CURVE_NCURVE', 'CURVE_PATH', 'CURVES',
    'EMPTY_ARROWS', 'EMPTY_AXIS', 'EMPTY_SINGLE_ARROW', 'MESH_CAPSULE', 'MESH_CIRCLE', 'MESH_CONE', 'MESH_CUBE', 'MESH_CYLINDER', 'MESH_GRID', 'MESH_ICOSPHERE', 'MESH_MONKEY',
    'MESH_PLANE', 'MESH_TORUS', 'MESH_UVSPHERE', 'META_BALL', 'META_CAPSULE', 'META_CUBE', 'META_ELLIPSOID', 'META_PLANE', 'MONKEY', 'SPHERE', 'STROKE',
    'SURFACE_NCIRCLE', 'SURFACE_NCURVE', 'SURFACE_NCYLINDER', 'SURFACE_NSPHERE', 'SURFACE_NSURFACE', 'SURFACE_NTORUS', 'TRIA_DOWN_BAR', 'TRIA_LEFT_BAR', 'TRIA_RIGHT_BAR', 'TRIA_UP_BAR', 'AREA_DOCK',
    'AREA_JOIN_DOWN', 'AREA_JOIN_LEFT', 'AREA_JOIN_UP', 'AREA_JOIN', 'AREA_SWAP', 'FORCE_BOID', 'FORCE_CHARGE', 'FORCE_CURVE', 'FORCE_DRAG', 'FORCE_FLUIDFLOW', 'FORCE_FORCE',
    'FORCE_HARMONIC', 'FORCE_LENNARDJONES', 'FORCE_MAGNETIC', 'FORCE_TEXTURE', 'FORCE_TURBULENCE', 'FORCE_VORTEX', 'FORCE_WIND', 'IMAGE_BACKGROUND', 'IMAGE_PLANE', 'IMAGE_REFERENCE', 'RIGID_BODY_CONSTRAINT',
    'RIGID_BODY', 'SPLIT_HORIZONTAL', 'SPLIT_VERTICAL', 'ANCHOR_BOTTOM', 'ANCHOR_CENTER', 'ANCHOR_LEFT', 'ANCHOR_RIGHT', 'ANCHOR_TOP', 'NODE_CORNER', 'NODE_INSERT_OFF', 'NODE_INSERT_ON',
    'NODE_SIDE', 'NODE_TOP', 'SELECT_EXTEND', 'SELECT_SET', 'SELECT_SUBTRACT', 'ALIGN_BOTTOM', 'ALIGN_CENTER', 'ALIGN_FLUSH', 'ALIGN_JUSTIFY', 'ALIGN_LEFT', 'ALIGN_MIDDLE',
    'ALIGN_RIGHT', 'ALIGN_TOP', 'BOLD', 'ITALIC', 'LINENUMBERS_OFF', 'LINENUMBERS_ON', 'SCRIPTPLUGINS', 'SMALL_CAPS', 'SYNTAX_OFF', 'SYNTAX_ON', 'UNDERLINE',
    'WORDWRAP_OFF', 'WORDWRAP_ON', 'CON_ACTION', 'CON_ARMATURE', 'CON_CAMERASOLVER', 'CON_CHILDOF', 'CON_CLAMPTO', 'CON_DISTLIMIT', 'CON_FLOOR', 'CON_FOLLOWPATH', 'CON_FOLLOWTRACK',
    'CON_KINEMATIC', 'CON_LOCKTRACK', 'CON_LOCLIKE', 'CON_LOCLIMIT', 'CON_OBJECTSOLVER', 'CON_PIVOT', 'CON_ROTLIKE', 'CON_ROTLIMIT', 'CON_SAMEVOL', 'CON_SHRINKWRAP', 'CON_SIZELIKE',
    'CON_SIZELIMIT', 'CON_SPLINEIK', 'CON_STRETCHTO', 'CON_TRACKTO', 'CON_TRANSFORM_CACHE', 'CON_TRANSFORM', 'CON_TRANSLIKE', 'HOOK', 'MOD_ARMATURE', 'MOD_ARRAY', 'MOD_BEVEL',
    'MOD_BOOLEAN', 'MOD_BUILD', 'MOD_CAST', 'MOD_CLOTH', 'MOD_CURVE', 'MOD_DASH', 'MOD_DATA_TRANSFER', 'MOD_DECIM', 'MOD_DISPLACE', 'MOD_DYNAMICPAINT', 'MOD_EDGESPLIT',
    'MOD_ENVELOPE', 'MOD_EXPLODE', 'MOD_FLUID', 'MOD_FLUIDSIM', 'MOD_HUE_SATURATION', 'MOD_INSTANCE', 'MOD_LATTICE', 'MOD_LENGTH', 'MOD_LINEART', 'MOD_MASK', 'MOD_MESHDEFORM',
    'MOD_MIRROR', 'MOD_MULTIRES', 'MOD_NOISE', 'MOD_NORMALEDIT', 'MOD_OCEAN', 'MOD_OFFSET', 'MOD_OPACITY', 'MOD_OUTLINE', 'MOD_PARTICLE_INSTANCE', 'MOD_PARTICLES', 'MOD_PHYSICS',
    'MOD_REMESH', 'MOD_SCREW', 'MOD_SHRINKWRAP', 'MOD_SIMPLEDEFORM', 'MOD_SIMPLIFY', 'MOD_SKIN', 'MOD_SMOOTH', 'MOD_SOFT', 'MOD_SOLIDIFY', 'MOD_SUBSURF', 'MOD_THICKNESS',
    'MOD_TIME', 'MOD_TINT', 'MOD_TRIANGULATE', 'MOD_UVPROJECT', 'MOD_VERTEX_WEIGHT', 'MOD_WARP', 'MOD_WAVE', 'MOD_WIREFRAME', 'MODIFIER_DATA', 'ACTION_SLOT', 'ACTION_TWEAK',
    'DRIVER', 'FF', 'FRAME_NEXT', 'FRAME_PREV', 'HANDLE_ALIGNED', 'HANDLE_AUTO', 'HANDLE_AUTOCLAMPED', 'HANDLE_FREE', 'HANDLE_VECTOR', 'IPO_BACK', 'IPO_BEZIER',
    'IPO_BOUNCE', 'IPO_CIRC', 'IPO_CONSTANT', 'IPO_CUBIC', 'IPO_EASE_IN_OUT', 'IPO_EASE_IN', 'IPO_EASE_OUT', 'IPO_ELASTIC', 'IPO_EXPO', 'IPO_LINEAR', 'IPO_QUAD',
    'IPO_QUART', 'IPO_QUINT', 'IPO_SINE', 'KEY_DEHLT', 'KEY_HLT', 'KEYFRAME_HLT', 'KEYFRAME', 'KEYINGSET', 'MARKER_HLT', 'MARKER', 'MUTE_IPO_OFF',
    'MUTE_IPO_ON', 'NEXT_KEYFRAME', 'NLA_PUSHDOWN', 'NORMALIZE_FCURVES', 'ORIENTATION_PARENT', 'PAUSE', 'PLAY_REVERSE', 'PLAY_SOUND', 'PLAY', 'PMARKER_ACT', 'PMARKER_SEL',
    'PMARKER', 'PREV_KEYFRAME', 'PREVIEW_RANGE', 'REC', 'REW', 'SOLO_OFF', 'SOLO_ON', 'CENTER_ONLY', 'CURSOR', 'EDGESEL', 'FACE_CORNER',
    'FACESEL', 'INVERSESQUARECURVE', 'LINCURVE', 'NOCURVE', 'PARTICLE_PATH', 'PARTICLE_POINT', 'PARTICLE_TIP', 'PIVOT_ACTIVE', 'PIVOT_BOUNDBOX', 'PIVOT_CURSOR', 'PIVOT_INDIVIDUAL',
    'PIVOT_MEDIAN', 'PROP_CON', 'PROP_OFF', 'PROP_ON', 'PROP_PROJECTED', 'RNDCURVE', 'ROOTCURVE', 'SHARPCURVE', 'SMOOTHCURVE', 'SPHERECURVE', 'VERTEXSEL',
    'SNAP_EDGE', 'SNAP_FACE_CENTER', 'SNAP_FACE_NEAREST', 'SNAP_FACE', 'SNAP_GRID', 'SNAP_INCREMENT', 'SNAP_MIDPOINT', 'SNAP_NORMAL', 'SNAP_PEEL_OBJECT', 'SNAP_PERPENDICULAR', 'SNAP_VERTEX',
    'SNAP_VOLUME', 'STICKY_UVS_DISABLE', 'STICKY_UVS_LOC', 'STICKY_UVS_VERT', 'ORIENTATION_GIMBAL', 'ORIENTATION_GLOBAL', 'ORIENTATION_LOCAL', 'ORIENTATION_NORMAL', 'ORIENTATION_VIEW', 'COPYDOWN', 'FIXED_SIZE',
    'GIZMO', 'GP_CAPS_FLAT', 'GP_CAPS_ROUND', 'NORMALS_FACE', 'NORMALS_VERTEX_FACE', 'NORMALS_VERTEX', 'OBJECT_ORIGIN', 'ORIENTATION_CURSOR', 'PASTEDOWN', 'PASTEFLIPDOWN', 'PASTEFLIPUP',
    'TRANSFORM_ORIGINS', 'UV_EDGESEL', 'UV_FACESEL', 'UV_ISLANDSEL', 'UV_SYNC_SELECT', 'UV_VERTEXSEL', 'AXIS_FRONT', 'AXIS_SIDE', 'AXIS_TOP', 'GRID', 'LAYER_ACTIVE',
    'LAYER_USED', 'LOCKVIEW_OFF', 'LOCKVIEW_ON', 'OVERLAY', 'SHADING_BBOX', 'SHADING_RENDERED', 'SHADING_SOLID', 'SHADING_TEXTURE', 'SHADING_WIRE', 'XRAY', 'VIEW_CAMERA_UNSELECTED',
    'VIEW_CAMERA', 'VIEW_LOCKED', 'VIEW_ORTHO', 'VIEW_PAN', 'VIEW_PERSPECTIVE', 'VIEW_UNLOCKED', 'VIEW_ZOOM', 'FILE_ALIAS', 'FILE_FOLDER', 'FOLDER_REDIRECT', 'APPEND_BLEND',
    'BACK', 'BOOKMARKS', 'CURRENT_FILE', 'DESKTOP', 'DISC', 'DISK_DRIVE', 'DOCUMENTS', 'EXPORT', 'EXTERNAL_DRIVE', 'FILE_3D', 'FILE_ARCHIVE',
    'FILE_BACKUP', 'FILE_BLANK', 'FILE_BLEND', 'FILE_CACHE', 'FILE_FONT', 'FILE_HIDDEN', 'FILE_IMAGE', 'FILE_MOVIE', 'FILE_PARENT', 'FILE_REFRESH', 'FILE_SCRIPT',
    'FILE_SOUND', 'FILE_TEXT', 'FILE_VOLUME', 'FILTER', 'FONTPREVIEW', 'FORWARD', 'HOME', 'IMGDISPLAY', 'IMPORT', 'LINK_BLEND', 'LONGDISPLAY',
    'LOOP_BACK', 'LOOP_FORWARDS', 'NETWORK_DRIVE', 'NEWFOLDER', 'SETTINGS', 'SHORTDISPLAY', 'SORT_ASC', 'SORT_DESC', 'SORTALPHA', 'SORTBYEXT', 'SORTSIZE',
    'SORTTIME', 'SYSTEM', 'TAG', 'TEMP', 'ALIASED', 'ANTIALIASED', 'MAT_SPHERE_SKY', 'MATCLOTH', 'MATCUBE', 'MATFLUID', 'MATPLANE',
    'MATSHADERBALL', 'MATSPHERE', 'SEQ_CHROMA_SCOPE', 'SEQ_HISTOGRAM', 'SEQ_LUMA_WAVEFORM', 'SEQ_PREVIEW', 'SEQ_SEQUENCER', 'SEQ_SPLITVIEW', 'SEQ_STRIP_DUPLICATE', 'SEQ_STRIP_META', 'IMAGE_ALPHA',
    'IMAGE_RGB_ALPHA', 'IMAGE_RGB', 'IMAGE_ZDEPTH', 'BLENDER_LOGO_LARGE', 'CANCEL_LARGE', 'DISC_LARGE', 'DISK_DRIVE_LARGE', 'EXTERNAL_DRIVE_LARGE', 'FILE_FOLDER_LARGE', 'FILE_LARGE', 'FILE_PARENT_LARGE',
    'INFO_LARGE', 'NETWORK_DRIVE_LARGE', 'QUESTION_LARGE', 'WARNING_LARGE', 'KEY_BACKSPACE_FILLED', 'KEY_BACKSPACE', 'KEY_COMMAND_FILLED', 'KEY_COMMAND', 'KEY_CONTROL_FILLED', 'KEY_CONTROL', 'KEY_EMPTY1_FILLED',
    'KEY_EMPTY1', 'KEY_EMPTY2_FILLED', 'KEY_EMPTY2', 'KEY_EMPTY3_FILLED', 'KEY_EMPTY3', 'KEY_MENU_FILLED', 'KEY_MENU', 'KEY_OPTION_FILLED', 'KEY_OPTION', 'KEY_RETURN_FILLED', 'KEY_RETURN',
    'KEY_RING_FILLED', 'KEY_RING', 'KEY_SHIFT_FILLED', 'KEY_SHIFT', 'KEY_TAB_FILLED', 'KEY_TAB', 'KEY_WINDOWS_FILLED', 'KEY_WINDOWS', 'FUND', 'HEART', 'INTERNET_OFFLINE',
    'INTERNET', 'USER', 'EXPERIMENTAL', 'MEMORY', 'KEYTYPE_KEYFRAME_VEC', 'KEYTYPE_BREAKDOWN_VEC', 'KEYTYPE_EXTREME_VEC', 'KEYTYPE_JITTER_VEC', 'KEYTYPE_MOVING_HOLD_VEC', 'KEYTYPE_GENERATED_VEC', 'HANDLETYPE_FREE_VEC',
    'HANDLETYPE_ALIGNED_VEC', 'HANDLETYPE_VECTOR_VEC', 'HANDLETYPE_AUTO_VEC', 'HANDLETYPE_AUTO_CLAMP_VEC', 'COLORSET_01_VEC', 'COLORSET_02_VEC', 'COLORSET_03_VEC', 'COLORSET_04_VEC', 'COLORSET_05_VEC', 'COLORSET_06_VEC', 'COLORSET_07_VEC',
    'COLORSET_08_VEC', 'COLORSET_09_VEC', 'COLORSET_10_VEC', 'COLORSET_11_VEC', 'COLORSET_12_VEC', 'COLORSET_13_VEC', 'COLORSET_14_VEC', 'COLORSET_15_VEC', 'COLORSET_16_VEC', 'COLORSET_17_VEC', 'COLORSET_18_VEC',
    'COLORSET_19_VEC', 'COLORSET_20_VEC', 'COLLECTION_COLOR_01', 'COLLECTION_COLOR_02', 'COLLECTION_COLOR_03', 'COLLECTION_COLOR_04', 'COLLECTION_COLOR_05', 'COLLECTION_COLOR_06', 'COLLECTION_COLOR_07', 'COLLECTION_COLOR_08', 'SEQUENCE_COLOR_01',
    'SEQUENCE_COLOR_02', 'SEQUENCE_COLOR_03', 'SEQUENCE_COLOR_04', 'SEQUENCE_COLOR_05', 'SEQUENCE_COLOR_06', 'SEQUENCE_COLOR_07', 'SEQUENCE_COLOR_08', 'SEQUENCE_COLOR_09', 'LIBRARY_DATA_INDIRECT', 'LIBRARY_DATA_OVERRIDE_NONEDITABLE', 'LAYERGROUP_COLOR_01',
    'LAYERGROUP_COLOR_02', 'LAYERGROUP_COLOR_03', 'LAYERGROUP_COLOR_04', 'LAYERGROUP_COLOR_05', 'LAYERGROUP_COLOR_06', 'LAYERGROUP_COLOR_07', 'LAYERGROUP_COLOR_08', 'EVENT_A', 'EVENT_B', 'EVENT_C', 'EVENT_D',
    'EVENT_E', 'EVENT_F', 'EVENT_G', 'EVENT_H', 'EVENT_I', 'EVENT_J', 'EVENT_K', 'EVENT_L', 'EVENT_M', 'EVENT_N', 'EVENT_O',
    'EVENT_P', 'EVENT_Q', 'EVENT_R', 'EVENT_S', 'EVENT_T', 'EVENT_U', 'EVENT_V', 'EVENT_W', 'EVENT_X', 'EVENT_Y', 'EVENT_Z',
    'EVENT_SHIFT', 'EVENT_CTRL', 'EVENT_ALT', 'EVENT_OS', 'EVENT_F1', 'EVENT_F2', 'EVENT_F3', 'EVENT_F4', 'EVENT_F5', 'EVENT_F6', 'EVENT_F7',
    'EVENT_F8', 'EVENT_F9', 'EVENT_F10', 'EVENT_F11', 'EVENT_F12', 'EVENT_F13', 'EVENT_F14', 'EVENT_F15', 'EVENT_F16', 'EVENT_F17', 'EVENT_F18',
    'EVENT_F19', 'EVENT_F20', 'EVENT_F21', 'EVENT_F22', 'EVENT_F23', 'EVENT_F24', 'EVENT_ESC', 'EVENT_TAB', 'EVENT_PAGEUP', 'EVENT_PAGEDOWN', 'EVENT_RETURN',
    'EVENT_SPACEKEY', 'EVENT_ZEROKEY', 'EVENT_ONEKEY', 'EVENT_TWOKEY', 'EVENT_THREEKEY', 'EVENT_FOURKEY', 'EVENT_FIVEKEY', 'EVENT_SIXKEY', 'EVENT_SEVENKEY', 'EVENT_EIGHTKEY', 'EVENT_NINEKEY',
    'EVENT_PAD0', 'EVENT_PAD1', 'EVENT_PAD2', 'EVENT_PAD3', 'EVENT_PAD4', 'EVENT_PAD5', 'EVENT_PAD6', 'EVENT_PAD7', 'EVENT_PAD8', 'EVENT_PAD9', 'EVENT_PADASTER',
    'EVENT_PADSLASH', 'EVENT_PADMINUS', 'EVENT_PADENTER', 'EVENT_PADPLUS', 'EVENT_PADPERIOD', 'EVENT_MOUSE_4', 'EVENT_MOUSE_5', 'EVENT_MOUSE_6', 'EVENT_MOUSE_7', 'EVENT_TABLET_STYLUS', 'EVENT_TABLET_ERASER',
    'EVENT_LEFT_ARROW', 'EVENT_DOWN_ARROW', 'EVENT_RIGHT_ARROW', 'EVENT_UP_ARROW', 'EVENT_PAUSE', 'EVENT_INSERT', 'EVENT_HOME', 'EVENT_END', 'EVENT_UNKNOWN', 'EVENT_GRLESS', 'EVENT_MEDIAPLAY',
    'EVENT_MEDIASTOP', 'EVENT_MEDIAFIRST', 'EVENT_MEDIALAST', 'EVENT_APP', 'EVENT_CAPSLOCK', 'EVENT_BACKSPACE', 'EVENT_DEL', 'EVENT_SEMICOLON', 'EVENT_PERIOD', 'EVENT_COMMA', 'EVENT_QUOTE',
    'EVENT_ACCENTGRAVE', 'EVENT_MINUS', 'EVENT_PLUS', 'EVENT_SLASH', 'EVENT_BACKSLASH', 'EVENT_EQUAL', 'EVENT_LEFTBRACKET', 'EVENT_RIGHTBRACKET', 'EVENT_NDOF_BUTTON_V1', 'EVENT_NDOF_BUTTON_V2', 'EVENT_NDOF_BUTTON_V3',
    'EVENT_NDOF_BUTTON_SAVE_V1', 'EVENT_NDOF_BUTTON_SAVE_V2', 'EVENT_NDOF_BUTTON_SAVE_V3', 'EVENT_NDOF_BUTTON_1', 'EVENT_NDOF_BUTTON_2', 'EVENT_NDOF_BUTTON_3', 'EVENT_NDOF_BUTTON_4', 'EVENT_NDOF_BUTTON_5', 'EVENT_NDOF_BUTTON_6', 'EVENT_NDOF_BUTTON_7', 'EVENT_NDOF_BUTTON_8',
    'EVENT_NDOF_BUTTON_9', 'EVENT_NDOF_BUTTON_10', 'EVENT_NDOF_BUTTON_11', 'EVENT_NDOF_BUTTON_12', 'EVENT_NDOF_BUTTON_MENU', 'EVENT_NDOF_BUTTON_FIT', 'EVENT_NDOF_BUTTON_TOP', 'EVENT_NDOF_BUTTON_BOTTOM', 'EVENT_NDOF_BUTTON_LEFT', 'EVENT_NDOF_BUTTON_RIGHT', 'EVENT_NDOF_BUTTON_FRONT',
    'EVENT_NDOF_BUTTON_BACK', 'EVENT_NDOF_BUTTON_ISO1', 'EVENT_NDOF_BUTTON_ISO2', 'EVENT_NDOF_BUTTON_ROLL_CW', 'EVENT_NDOF_BUTTON_ROLL_CCW', 'EVENT_NDOF_BUTTON_SPIN_CW', 'EVENT_NDOF_BUTTON_SPIN_CCW', 'EVENT_NDOF_BUTTON_TILT_CW', 'EVENT_NDOF_BUTTON_TILT_CCW', 'EVENT_NDOF_BUTTON_ROTATE', 'EVENT_NDOF_BUTTON_PANZOOM',
    'EVENT_NDOF_BUTTON_DOMINANT', 'EVENT_NDOF_BUTTON_PLUS', 'EVENT_NDOF_BUTTON_MINUS',
]
BL_ID = 'ICON_PT_Panel'
BL_CATAGORY = 'Development'
BL_SPACE = 'VIEW_3D'
BL_REGION = 'UI'
def Props(context): return context.scene.search_props


class DefaultPanel:
    bl_space_type = BL_SPACE
    bl_region_type = BL_REGION
    bl_category = BL_CATAGORY
    bl_options = {"DEFAULT_CLOSED"}


class ExpandedPanel(DefaultPanel):
    bl_options = {"HEADER_LAYOUT_EXPAND"}


def update_search(self, context):
    search_pattern = self.search.upper()
    try:
        regex = re.compile(search_pattern)
        self.filtered_icons.clear()
        for icon in ICONS:
            if regex.search(icon):
                item = self.filtered_icons.add()
                item.name = icon
    except re.error:
        self.filtered_icons.clear()

    # 触发面板重绘
    for area in context.screen.areas:
        if area.type == 'PROPERTIES':
            area.tag_redraw()


class IconItem(bpy.types.PropertyGroup):
    name: bpy.props.StringProperty()


class SearchProperty(bpy.types.PropertyGroup):
    search: bpy.props.StringProperty(
        name="",
        description="Search",
        default="",
        update=update_search,
    )  # type: ignore
    filtered_icons: bpy.props.CollectionProperty(
        type=IconItem  # type: ignore
    )


class CopyOperator(bpy.types.Operator):
    bl_idname = "wm.copy_icon_name"
    bl_label = "Copy"
    bl_description = "Copy"
    # bl_options = {"REGISTER"}
    name: bpy.props.StringProperty()

    def execute(self, context):
        context.window_manager.clipboard = f"{self.name}"  # CHANGE THIS LINE IF YOU DON'T LIKE QUOTES
        self.report({'INFO'}, f"Copied {self.name} to clipboard")
        return {"FINISHED"}


class Search_PT_Panel(ExpandedPanel, bpy.types.Panel):
    bl_idname = BL_ID
    bl_label = "Icon"

    def draw(self, context):
        layout = self.layout
        props = Props(context)
        row = layout.row()
        row.prop(props, 'search')


class ListPanel(ExpandedPanel, bpy.types.Panel):
    bl_label = "Result"
    bl_parent_id = BL_ID

    def draw(self, context):
        props = Props(context)
        col = self.layout.column(align=True)
        for i in props.filtered_icons:
            row = col.row(align=True)
            op = col.operator("wm.copy_icon_name", text=i.name, icon=i.name)
            op.name = i.name


CLASS = [
    IconItem,
    SearchProperty,
    CopyOperator,
    Search_PT_Panel,
    ListPanel,
]


def register():
    for cls in CLASS:
        bpy.utils.register_class(cls)
    bpy.types.Scene.search_props = bpy.props.PointerProperty(type=SearchProperty)

    def init_props(scene):
        props = Props(bpy.context)
        for i in ICONS:
            item = props.filtered_icons.add()
            item.name = i
    bpy.app.timers.register(init_props, first_interval=0.1)


def unregister():
    for cls in CLASS:
        bpy.utils.unregister_class(cls)
    del bpy.types.Scene.search_props


if __name__ == "__main__":
    try:
        unregister()
    except Exception as e:
        print('⚠️', e)
    register()
